# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms.time_sensor.time_after_05_30 import time_after_05_30

jms_dwd__dwm_sign_warning_detail = SparkSqlOperator(
    task_id='jms_dwd__dwm_sign_warning_detail',
    email=['lukunming@jtexpress.com','yl_bigdata@yl-scm.com'],
    master='yarn',
    name='jms_dwd__dwm_sign_warning_detail_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dwd/dwm_sign_warning_detail/execute.hql',
    pool_slots=2,
    driver_cores=4,
    driver_memory='10g',
    executor_cores=4,
    executor_memory='12G',
    num_executors=30,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
          'spark.dynamicAllocation.maxExecutors'             : 50,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 600,
          'spark.network.timeout' : 600,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
          'spark.executor.memoryOverhead'                    : '5G',
          'spark.sql.shuffle.partitions'                     : 1200
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 80,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 80,  # 最大分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=30),
    retries=0,
    sla=timedelta(hours=2)
)
jms_dwd__dwm_sign_warning_detail << [time_after_05_30]
